package middleware

import (
	comJwt "common/jwt"
	"gateway/internal/config"
	"net/http"
)

type UserInfoMiddleware struct {
	Config config.Config
}

func NewUserInfoMiddleware(c config.Config) *UserInfoMiddleware {
	return &UserInfoMiddleware{
		Config: c,
	}
}

func (m *UserInfoMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		comJwt.DefatHandle(w, r, next, m.Config.Auth)
	}
}
